/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.project;

import org.apache.commons.lang3.StringUtils;

/**
 * 特殊指标类型
 * @author zpy
 * @version 1.0.0
 */
public enum SpecialType {
    /**
     * 升级指标
     */
    UPGRADE(1,"升级指标"),
    /**
     * 引用指标
     */
    UPLEVEL(2,"引用指标"),
    /**
     * 自定义指标
     */
    CUSTOM(3,"自定义指标");

    private final int type;
    private final String name;

    SpecialType(int targetType, String name) {
        this.type = targetType;
        this.name = name;
    }

    public static SpecialType fromType(Integer type){
        SpecialType data = UPGRADE;
        for(SpecialType tt :SpecialType.values()){
            if(tt.type == type){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static SpecialType fromName(String name){
        SpecialType data = UPGRADE;
        for(SpecialType tt :SpecialType.values()){
            if(StringUtils.equals(tt.name,name)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public int getType(){
        return this.type;
    }

    public String getName(){
        return this.name;
    }
}